package 双指针;

import com.sun.javafx.image.BytePixelSetter;

/**
 * @Author：小鹿爱吃鱼
 * @Date: 2025/5/7 22:09
 * @Description:
 */
public class 移动零 {

    // [0,1,0,3,12]
    public void moveZeroes(int[] nums) {
        int j = nums.length - 1;
        for (int i = 0; i < j; i++) {
            if(nums[i] == 0) {
                int temp = nums[i];
                nums[i] = nums[j];
                nums[j] = temp;
                j--;
                if(nums[i] == 0) {
                    i--;
                }
            }
        }
    }

    public static void main(String[] args) {

    }
}
